const tt = window["tt"];

import SdkManager from './SdkManager';
import SdkUIBase from './SdkUIBase';

const { ccclass, property } = cc._decorator;
@ccclass
export class SidebarRewardDialog extends SdkUIBase {    
    protected onLoad(): void {
        super.onLoad();
        // 显示按钮文本
        this.getChild("lbl_cost").getComponent(cc.Label).string = window["isFromeSidebar"] ? "领取奖励" : "进入侧边栏";
    }

    private mainClickCb() {
        if (!window["isFromeSidebar"]) {
            tt.navigateToScene({
                scene: 'sidebar',
                fail: console.log,
                success: console.log
            });
        } 
    }
    
    protected update(dt: number): void {
        if (window["isFromeSidebar"]) {
            // 从侧边栏进入的领取奖励
            SdkManager.Instance().getSideBarReward();
            this.uiData.cb();
            console.log("获得侧边栏奖励");
            this.close();
        }
    }
}


